package com.example.calculation;


import com.example.entity.Effect;

public class SkillEffect implements Cloneable{

    private boolean canCal = true;

    //烤技法
    protected int bake;
    //煮技法
    protected int boil;
    //炒技法
    protected int stirfry;
    //切技法
    protected int knife;
    //炸技法
    protected int fry;
    //蒸技法
    protected int steam;

    //烤技法
    protected double bakePercent;
    //煮技法
    protected double boilPercent;
    //炒技法
    protected double stirfryPercent;
    //切技法
    protected double knifePercent;
    //炸技法
    protected double fryPercent;
    //蒸技法
    protected double steamPercent;

    //烤技法 百分比加成
    protected double usebake;
    //煮技法 百分比加成
    protected double useboil;
    //炒技法 百分比加成
    protected double usestirfry;
    //切技法 百分比加成
    protected double useknife;
    //炸技法 百分比加成
    protected double usefry;
    //蒸技法 百分比加成
    protected double usesteam;
    //鱼类 百分比加成
    protected double usefish;
    //面类 百分比加成
    protected double usecreation;
    //肉 百分比加成
    protected double usemeat;
    //蔬菜 百分比加成
    protected double usevegetable;
    //金币加成
    protected double goldgain;

    //临时加成 有些厨师能给其他厨师提供技法加成，这一部分加成封装在TempAddtion中
    protected TempAddtion tempAddtion = null;

    @Override
    public SkillEffect clone() {
        SkillEffect old = null;
        try {
            old = (SkillEffect) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return old;
    }

    public void effect(Effect effect) {
        //全体上场厨师技法提升类
        if ("Partial".equals(effect.getCondition())) {
            if (tempAddtion == null) {
                tempAddtion = new TempAddtion();
            }
            switch (effect.getType()) {
                case "Bake":
                    tempAddtion.bake += effect.getValue();
                    break;
                case "Steam":
                    tempAddtion.steam += effect.getValue();
                    break;
                case "Boil":
                    tempAddtion.boil += effect.getValue();
                    break;
                case "Fry":
                    tempAddtion.fry += effect.getValue();
                    break;
                case "Knife":
                    tempAddtion.knife += effect.getValue();
                    break;
                case "Stirfry":
                    tempAddtion.stirfry += effect.getValue();
                    break;
                default:
                    break;
            }
        } else if ("Self".equals(effect.getCondition())) {
            switch (effect.getType()) {
                case "Bake":

                    if (effect.getCal().equals("Abs")) {
                        bake += effect.getValue();
                    } else if (effect.getCal().equals("Percent")) {
                        bakePercent += effect.getValue().doubleValue() / 100;
                    }

                    break;
                case "Steam":
                    if (effect.getCal().equals("Abs")) {
                        steam += effect.getValue();
                    } else if (effect.getCal().equals("Percent")) {
                        steamPercent += effect.getValue().doubleValue() / 100;
                    }

                    break;
                case "Boil":
                    if (effect.getCal().equals("Abs")) {
                        boil += effect.getValue();
                    } else if (effect.getCal().equals("Percent")) {
                        boilPercent += (effect.getValue().doubleValue() / 100);
                    }

                    break;
                case "Fry":
                    if (effect.getCal().equals("Abs")) {
                        fry += effect.getValue();
                    } else if (effect.getCal().equals("Percent")) {
                        fryPercent += (effect.getValue().doubleValue() / 100);
                    }

                    break;
                case "Knife":
                    if (effect.getCal().equals("Abs")) {
                        knife += effect.getValue();
                    } else if (effect.getCal().equals("Percent")) {
                        knifePercent += effect.getValue().doubleValue() / 100;
                    }

                    break;
                case "Stirfry":
                    if (effect.getCal().equals("Abs")) {
                        stirfry += effect.getValue();
                    } else if (effect.getCal().equals("Percent")) {
                        stirfryPercent += effect.getValue().doubleValue() / 100;
                    }
                    break;
                case "UseBake":
                    usebake += effect.getValue().doubleValue() / 100;
                    break;
                case "UseSteam":
                    usesteam += effect.getValue().doubleValue() / 100;
                    break;
                case "UseBoil":
                    useboil += effect.getValue().doubleValue() / 100;
                    break;
                case "UseFry":
                    usefry += effect.getValue().doubleValue() / 100;
                    break;
                case "UseKnife":
                    useknife += effect.getValue().doubleValue() / 100;
                    break;
                case "UseStirfry":
                    usestirfry += effect.getValue().doubleValue() / 100;
                    break;
                case "UseFish":
                    usefish += effect.getValue().doubleValue() / 100;
                    break;
                case "UseCreation":
                    usecreation += effect.getValue().doubleValue() / 100;
                    break;
                case "UseMeat":
                    usemeat += effect.getValue().doubleValue() / 100;
                    break;
                case "UseVegetable":
                    usevegetable += effect.getValue().doubleValue() / 100;
                    break;
                case "Gold_Gain":
                    goldgain += effect.getValue().doubleValue() / 100;
                    break;

                //暂时不考虑无限的修炼技能

//                case "MutiEquipmentSkill":  //厨具效果翻倍
//                    Integer value = effect.getValue();
//                    boil *= (1 + value);
//                    bake *= (1 + value);
//                    fry *= (1 + value);
//                    knife *= (1 + value);
//                    steam *= (1 + value);
//                    stirfry *= (1 + value);
//                    boilPercent *= (1 + value);
//                    bakePercent *= (1 + value);
//                    fryPercent *= (1 + value);
//                    knifePercent *= (1 + value);
//                    steamPercent *= (1 + value);
//                    stirfryPercent *= (1 + value);
//                    usebake *= (1 + value);
//                    useboil *= (1 + value);
//                    usestirfry *= (1 + value);
//                    useknife *= (1 + value);
//                    usefry *= (1 + value);
//                    usesteam *= (1 + value);
//                    usefish *= (1 + value);
//                    usecreation *= (1 + value);
//                    usemeat *= (1 + value);
//                    usevegetable *= (1 + value);
//                    goldgain *= (1 + value);
//                    break;
                default:
                    break;
            }
        }
    }


    public void globalEffect(GlobalAddtion globalAddtion) {
        bake += globalAddtion.bake;
        boil += globalAddtion.boil;
        stirfry += globalAddtion.stirfry;
        knife += globalAddtion.knife;
        fry += globalAddtion.fry;
        steam += globalAddtion.steam;
    }

    public void templeEffect(TempAddtion tempAddtion) {
        bake += tempAddtion.bake;
        boil += tempAddtion.boil;
        stirfry += tempAddtion.stirfry;
        knife += tempAddtion.knife;
        fry += tempAddtion.fry;
        steam += tempAddtion.steam;
    }

    public void calSkill() {
        if (canCal) {

        }
        canCal = false;
    }

    public void addEffect(SkillEffect effect) {
            usesteam += effect.usesteam;
            useboil += effect.useboil;
            usefry += effect.usefry;
            useknife += effect.useknife;
            usestirfry += effect.usestirfry;
            usefish += effect.usefish;
            usecreation += effect.usecreation;
            usemeat += effect.usemeat;
            usevegetable += effect.usevegetable;
            goldgain += effect.goldgain;
            bake += effect.bake;
            boil += effect.boil;
            stirfry += effect.stirfry;
            knife += effect.knife;
            fry += effect.fry;
            steam += effect.steam;
            bakePercent += effect.bakePercent;
            boilPercent += effect.boilPercent;
            stirfryPercent += effect.stirfryPercent;
            knifePercent += effect.knifePercent;
            fryPercent += effect.fryPercent;
            steamPercent += effect.steamPercent;
            if (effect.tempAddtion != null) {
                if (this.tempAddtion == null) {
                    this.tempAddtion = new TempAddtion();
                }
                this.tempAddtion.bake += effect.tempAddtion.bake;
                this.tempAddtion.boil += effect.tempAddtion.boil;
                this.tempAddtion.stirfry += effect.tempAddtion.stirfry;
                this.tempAddtion.knife += effect.tempAddtion.knife;
                this.tempAddtion.fry += effect.tempAddtion.fry;
                this.tempAddtion.steam += effect.tempAddtion.steam;
            }
    }


    public void reset() {
        usesteam = 0;
        useboil = 0;
        usefry = 0;
        useknife = 0;
        usestirfry = 0;
        usefish = 0;
        usecreation = 0;
        usemeat = 0;
        usevegetable = 0;
        goldgain = 0;
        bake = 0;
        boil = 0;
        stirfry = 0;
        knife = 0;
        fry = 0;
        steam = 0;
        bakePercent = 0;
        boilPercent = 0;
        stirfryPercent = 0;
        knifePercent = 0;
        fryPercent = 0;
        steamPercent = 0;
        if (this.tempAddtion != null) {
            this.tempAddtion.bake = 0;
            this.tempAddtion.boil = 0;
            this.tempAddtion.stirfry = 0;
            this.tempAddtion.knife = 0;
            this.tempAddtion.fry = 0;
            this.tempAddtion.steam = 0;
        }
    }

    public boolean isCanCal() {
        return canCal;
    }

    public void setCanCal(boolean canCal) {
        this.canCal = canCal;
    }

    public int getBake() {
        return bake;
    }

    public void setBake(int bake) {
        this.bake = bake;
    }

    public int getBoil() {
        return boil;
    }

    public void setBoil(int boil) {
        this.boil = boil;
    }

    public int getStirfry() {
        return stirfry;
    }

    public void setStirfry(int stirfry) {
        this.stirfry = stirfry;
    }

    public int getKnife() {
        return knife;
    }

    public void setKnife(int knife) {
        this.knife = knife;
    }

    public int getFry() {
        return fry;
    }

    public void setFry(int fry) {
        this.fry = fry;
    }

    public int getSteam() {
        return steam;
    }

    public void setSteam(int steam) {
        this.steam = steam;
    }

    public double getBakePercent() {
        return bakePercent;
    }

    public void setBakePercent(double bakePercent) {
        this.bakePercent = bakePercent;
    }

    public double getBoilPercent() {
        return boilPercent;
    }

    public void setBoilPercent(double boilPercent) {
        this.boilPercent = boilPercent;
    }

    public double getStirfryPercent() {
        return stirfryPercent;
    }

    public void setStirfryPercent(double stirfryPercent) {
        this.stirfryPercent = stirfryPercent;
    }

    public double getKnifePercent() {
        return knifePercent;
    }

    public void setKnifePercent(double knifePercent) {
        this.knifePercent = knifePercent;
    }

    public double getFryPercent() {
        return fryPercent;
    }

    public void setFryPercent(double fryPercent) {
        this.fryPercent = fryPercent;
    }

    public double getSteamPercent() {
        return steamPercent;
    }

    public void setSteamPercent(double steamPercent) {
        this.steamPercent = steamPercent;
    }

    public double getUsebake() {
        return usebake;
    }

    public void setUsebake(double usebake) {
        this.usebake = usebake;
    }

    public double getUseboil() {
        return useboil;
    }

    public void setUseboil(double useboil) {
        this.useboil = useboil;
    }

    public double getUsestirfry() {
        return usestirfry;
    }

    public void setUsestirfry(double usestirfry) {
        this.usestirfry = usestirfry;
    }

    public double getUseknife() {
        return useknife;
    }

    public void setUseknife(double useknife) {
        this.useknife = useknife;
    }

    public double getUsefry() {
        return usefry;
    }

    public void setUsefry(double usefry) {
        this.usefry = usefry;
    }

    public double getUsesteam() {
        return usesteam;
    }

    public void setUsesteam(double usesteam) {
        this.usesteam = usesteam;
    }

    public double getUsefish() {
        return usefish;
    }

    public void setUsefish(double usefish) {
        this.usefish = usefish;
    }

    public double getUsecreation() {
        return usecreation;
    }

    public void setUsecreation(double usecreation) {
        this.usecreation = usecreation;
    }

    public double getUsemeat() {
        return usemeat;
    }

    public void setUsemeat(double usemeat) {
        this.usemeat = usemeat;
    }

    public double getUsevegetable() {
        return usevegetable;
    }

    public void setUsevegetable(double usevegetable) {
        this.usevegetable = usevegetable;
    }

    public double getGoldgain() {
        return goldgain;
    }

    public void setGoldgain(double goldgain) {
        this.goldgain = goldgain;
    }

    public TempAddtion getTempAddtion() {
        return tempAddtion;
    }

    public void setTempAddtion(TempAddtion tempAddtion) {
        this.tempAddtion = tempAddtion;
    }
}
